package homeWork;

import java.util.Scanner;

public class homeWork7 {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个整数");
        int num = sc.nextInt();
        int result = 0;
        for (int i = 1; i <= num ; i++) {
            result += factorial(i);
        }
        System.out.println("阶乘和为：" + result);
    }
    public static int factorial(int sum){
        int result = 1;
        for (int i = 2; i <= sum ; i++) {
            result *= i;
        }
        return result;
    }
}
